package de.fhaugsburg.games.boardgames.scrabble.gui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;

import javax.swing.BorderFactory;
import javax.swing.JLayeredPane;

public class GSquare extends JLayeredPane {

	private BufferedImage backgroundImage;
	private String toolTip;
	private int row, column;

	
	
	public GSquare(int row, int column) {
		super();
		this.row = row;
		this.column = column;
		setDoubleBuffered(true);
		setPreferredSize(new Dimension(30, 30));
	 	setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY, 1));
	 	setLayer(this, DEFAULT_LAYER);
	}


	public void paintComponent(Graphics g) {
		super.paintComponent(g);
		
		if (backgroundImage != null){
		    Graphics2D g2d = (Graphics2D) g;
			g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
			g2d.drawImage(backgroundImage, 0, 0, backgroundImage.getWidth(), backgroundImage.getHeight(), this);
		}
		//FIXME: use cross-plattform fonts
//		Font font = new Font("Arial",Font.PLAIN, 6);
//		g.drawString(backgroundDescription, 8, 8);
	}
	
	
	
	public BufferedImage getBackgroundImage() {
		return backgroundImage;
	}


	public void setBackgroundImage(BufferedImage backgroundImage) {
		this.backgroundImage = backgroundImage;
	}


	public String getToolTip() {
		return toolTip;
	}


	public void setToolTip(String toolTip) {
		this.toolTip = toolTip;
	}


	/**
	 * @param row the row to set
	 */
	private void setRow(int row) {
		this.row = row;
	}


	/**
	 * @return the row
	 */
	public int getRow() {
		return row;
	}


	/**
	 * @param column the column to set
	 */
	private void setColumn(int column) {
		this.column = column;
	}


	/**
	 * @return the column
	 */
	public int getColumn() {
		return column;
	}


	
}
